﻿using Abp.Authorization;
using Abp.Localization;

namespace ARchGL.Platform.Electrocar.Authorization
{
    public class AppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var permission = context.GetPermissionOrNull(AppPermissions.Electrocar)
                ?? context.CreatePermission(AppPermissions.Electrocar, L(AppPermissions.Electrocar));

            var car = permission.CreateChildPermission(AppPermissions.Electrocar_Car, L("Car"));
            car.CreateChildPermission(AppPermissions.Electrocar_CreateCar, L("CreateCar"));
            car.CreateChildPermission(AppPermissions.Electrocar_DeleteCar, L("DeleteCar"));
            car.CreateChildPermission(AppPermissions.Electrocar_EditCar, L("EditCar"));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static ILocalizableString L(string name)
        {
            return new LocalizableString(name, PlatformConsts.LocalizationSourceName);
        }
    }
}
